
<h1><span class="yiyi-st" id="yiyi-12">numpy.nper</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.nper.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.nper.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.nper"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">nper</code><span class="sig-paren">(</span><em>rate</em>, <em>pmt</em>, <em>pv</em>, <em>fv=0</em>, <em>when=&apos;end&apos;</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/lib/financial.py#L218-L284"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">计算定期付款的数量。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>rate</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17">利率（每期）</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-18"><strong>pmt</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">付款</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-20"><strong>pv</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-21">目前价值</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-22"><strong>fv</strong>：array_like，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-23">未来价值</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-24"><strong>时</strong>：{{&apos;begin&apos;，1}，{&apos;end&apos;，0}}，{string，int}</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-25">付款到期时（“开始”（1）或“结束”（0））</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric"><span class="yiyi-st" id="yiyi-26">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-27">周期数<code class="docutils literal"><span class="pre">nper</span></code>通过求解以下等式来计算：</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">fv</span> <span class="o">+</span> <span class="n">pv</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">rate</span><span class="p">)</span><span class="o">**</span><span class="n">nper</span> <span class="o">+</span> <span class="n">pmt</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">rate</span><span class="o">*</span><span class="n">when</span><span class="p">)</span><span class="o">/</span><span class="n">rate</span><span class="o">*</span><span class="p">((</span><span class="mi">1</span><span class="o">+</span><span class="n">rate</span><span class="p">)</span><span class="o">**</span><span class="n">nper</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">=</span> <span class="mi">0</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-28">但是如果<code class="docutils literal"><span class="pre">rate</span> <span class="pre">=</span> <span class="pre">0</span></code></span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">fv</span> <span class="o">+</span> <span class="n">pv</span> <span class="o">+</span> <span class="n">pmt</span><span class="o">*</span><span class="n">nper</span> <span class="o">=</span> <span class="mi">0</span>
</pre></div>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-29">例子</span></p>
<p><span class="yiyi-st" id="yiyi-30">如果你只有150美元/月支付贷款，需要多长时间以7％的年利率偿还8,000美元的贷款？</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">nper</span><span class="p">(</span><span class="mf">0.07</span><span class="o">/</span><span class="mi">12</span><span class="p">,</span> <span class="o">-</span><span class="mi">150</span><span class="p">,</span> <span class="mi">8000</span><span class="p">),</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">64.07335</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-31">所以，超过64个月将需要偿还贷款。</span></p>
<p><span class="yiyi-st" id="yiyi-32">可以用几种不同的利率和/或付款和/或总金额进行相同的分析以产生整个表格。</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">nper</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ogrid</span><span class="p">[</span><span class="mf">0.07</span><span class="o">/</span><span class="mi">12</span><span class="p">:</span> <span class="mf">0.08</span><span class="o">/</span><span class="mi">12</span><span class="p">:</span> <span class="mf">0.01</span><span class="o">/</span><span class="mi">12</span><span class="p">,</span>
<span class="gp">... </span>                   <span class="o">-</span><span class="mi">150</span>   <span class="p">:</span> <span class="o">-</span><span class="mi">99</span>     <span class="p">:</span> <span class="mi">50</span>    <span class="p">,</span>
<span class="gp">... </span>                   <span class="mi">8000</span>   <span class="p">:</span> <span class="mi">9001</span>    <span class="p">:</span> <span class="mi">1000</span><span class="p">]))</span>
<span class="go">array([[[  64.07334877,   74.06368256],</span>
<span class="go">        [ 108.07548412,  127.99022654]],</span>
<span class="go">       [[  66.12443902,   76.87897353],</span>
<span class="go">        [ 114.70165583,  137.90124779]]])</span>
</pre></div>
</div>
</dd></dl>
